home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / timings.arc / TIMERT03.ASM < prev    next >
Assembly Source File  |  1986-01-18  |  3KB  |  146 lines

  1.     title    TIMERT03 -- High Resolution Timer Test Skeleton
  2.     page    60,120
  3.  
  4.     name    TIMERT03    ; module
  5.  
  6. comment |         Module Specifications
  7.  
  8. Copyright: None.
  9.  
  10. Environment: IBM PC, tested under DOS 2.0.
  11.  
  12. Segmentation: Program segment CODE, public, byte aligned, class ''.
  13.           Stack segment STACK, stack, paragraph aligned, class ''.
  14.           Data segment DATA, public, byte aligned, class ''.
  15.  
  16. Public symbols and external references: See Symbols section of listing.
  17.  
  18. Link requirements: EXE module, must be linked with TIMERS01 and TIMERR02,
  19.             and any external code to be included in test.
  20.  
  21. Program derived from: None.
  22.  
  23. Original code by: Bob Smith and Tom Puckett, October 1983.
  24.  
  25. Modifications by: None.
  26.  
  27.  
  28.             Procedure Specifications
  29.  
  30. Program TIMERT03 -- High Resolution Timer Test Program Skeleton
  31.  
  32.     This is the skeleton of a control routine to be used in running
  33.     high resolution timing tests.  The code to be tested is included
  34.     in this module or called from it.  This routine calls subroutines
  35.     TIMERS01 and TIMERR02 for setting and reading Counter 0 of the 8253.
  36.     It is normally run under DEBUG to allow a breakpoint to be set to
  37.     examine the results of the timing test.
  38.  
  39.     Assumptions: None.
  40.  
  41.     Linkage: DOS command.
  42.  
  43.     Arguments: None.
  44.  
  45.     Effects: 8253 Counter 0 reset by routine TIMERS01.
  46.  
  47.     Results: None.
  48.  
  49.     Return conditions: None.
  50.  
  51.     Limitations: Gives incorrect results if test run spans midnight.
  52. |
  53.     page
  54.  
  55. stack    segment stack para
  56.  
  57.     db    32 dup ('stack   ')    ; you may wish to increase this if
  58.                     ;   the routine being tested makes
  59. stack    ends                ;   heavy demands on the stack
  60.  
  61.  
  62.  
  63. data    segment public byte
  64.  
  65. a_cal_high    dw    ?        ; first timer readings...
  66. a_cal_low    dw    ?
  67. a_cal_ext    dw    ?
  68.  
  69. b_cal_high    dw    ?        ; second timer readings....
  70. b_cal_low    dw    ?
  71. b_cal_ext    dw    ?
  72.  
  73. ;    other storage needed by routine being tested can be included here...
  74.  
  75. data    ends
  76.  
  77.  
  78.  
  79. code    segment public byte
  80.     assume    cs:code
  81.  
  82.     extrn    timers01:near    ; 8253 Counter 0 set routine
  83.     extrn    timerr02:near    ; 8253 Counter 0 read routine
  84.  
  85.     public    TIMERT03
  86. TIMERT03 proc    far        ; see specifications at head of listing
  87.  
  88.     push    ds        ; make return linkage
  89.     xor    ax,ax
  90.     push    ax
  91.     mov    ax,data        ; get data segment addressible
  92.     mov    ds,ax
  93.     assume    ds:data
  94.     call    tester        ; do the work
  95.     ret
  96.  
  97. TIMERT03 endp
  98.     page
  99.  
  100. tester    proc    near
  101.  
  102.     call    timers01    ; get 8253 counter 0 running in Mode 2
  103.  
  104.     call    timerr02    ; begin calibration pass
  105.     mov    a_cal_ext,cx
  106.     mov    a_cal_low,bx
  107.     mov    a_cal_high,ax    ; initial extended timer count now saved
  108.  
  109. calib_begin:
  110. ;        put here any test code whose effect is to be removed
  111. ;        from the results, such as loop control statements...
  112. calib_end:
  113.  
  114.     call    timerr02    ; end of calibration pass, begin test pass
  115.     mov    b_cal_ext,cx
  116.     mov    b_cal_low,bx
  117.     mov    b_cal_high,ax
  118.  
  119. test_begin:
  120. ;        put test code here...
  121. test_end:
  122.  
  123.     call    timerr02    ; end of test pass
  124.  
  125.     add    cx,a_cal_ext    ; calculate (C-B)-(B-A) as ((C+A)-B)-B...
  126.     adc    bx,a_cal_low    ; ADC to allow for carry in preceding ADD
  127.     adc    ax,a_cal_high    ; now have C+A
  128.  
  129.     sub    cx,b_cal_ext
  130.     sbb    bx,b_cal_low
  131.     sbb    ax,b_cal_high    ; now have (C+A)-B
  132.  
  133.     sub    cx,b_cal_ext
  134.     sbb    bx,b_cal_low
  135.     sbb    ax,b_cal_high    ; now have ((C+A)-B)-B in timer counts as
  136.                 ;   a six byte field in AX, BX, and CX
  137.  
  138. halt:                ; put DEBUG breakpoint here to examine results
  139.     ret
  140.  
  141. tester    endp
  142.  
  143. code    ends
  144.  
  145.     end    TIMERT03
  146.